#ifndef __VESC_H__
#define __VESC_H__

#include "can.h"


/******************Դ���е�CAN_ID******************/
typedef enum {
    CAN_PACKET_SET_DUTY = 0,
    CAN_PACKET_SET_CURRENT,
    CAN_PACKET_SET_CURRENT_BRAKE,
    CAN_PACKET_SET_RPM,
    CAN_PACKET_SET_POS,
    CAN_PACKET_FILL_RX_BUFFER,
    CAN_PACKET_FILL_RX_BUFFER_LONG,
    CAN_PACKET_PROCESS_RX_BUFFER,
    CAN_PACKET_PROCESS_SHORT_BUFFER,
    CAN_PACKET_STATUS,
    CAN_PACKET_SET_CURRENT_REL,
    CAN_PACKET_SET_CURRENT_BRAKE_REL,
    CAN_PACKET_SET_CURRENT_HANDBRAKE,
    CAN_PACKET_SET_CURRENT_HANDBRAKE_REL,
    CAN_PACKET_STATUS_2,
    CAN_PACKET_STATUS_3,
    CAN_PACKET_STATUS_4,
    CAN_PACKET_PING,
    CAN_PACKET_PONG,
    CAN_PACKET_DETECT_APPLY_ALL_FOC,
    CAN_PACKET_DETECT_APPLY_ALL_FOC_RES,
    CAN_PACKET_CONF_CURRENT_LIMITS,
    CAN_PACKET_CONF_STORE_CURRENT_LIMITS,
    CAN_PACKET_CONF_CURRENT_LIMITS_IN,
    CAN_PACKET_CONF_STORE_CURRENT_LIMITS_IN,
    CAN_PACKET_CONF_FOC_ERPMS,
    CAN_PACKET_CONF_STORE_FOC_ERPMS,
    CAN_PACKET_STATUS_5,
    CAN_PACKET_POLL_TS5700N8501_STATUS,
    CAN_PACKET_CONF_BATTERY_CUT,
    CAN_PACKET_CONF_STORE_BATTERY_CUT,
    CAN_PACKET_SHUTDOWN,
    CAN_PACKET_IO_BOARD_ADC_1_TO_4,
    CAN_PACKET_IO_BOARD_ADC_5_TO_8,
    CAN_PACKET_IO_BOARD_ADC_9_TO_12,
    CAN_PACKET_IO_BOARD_DIGITAL_IN,
    CAN_PACKET_IO_BOARD_SET_OUTPUT_DIGITAL,
    CAN_PACKET_IO_BOARD_SET_OUTPUT_PWM,
    CAN_PACKET_BMS_V_TOT,
    CAN_PACKET_BMS_I,
    CAN_PACKET_BMS_AH_WH,
    CAN_PACKET_BMS_V_CELL,
    CAN_PACKET_BMS_BAL,
    CAN_PACKET_BMS_TEMPS,
    CAN_PACKET_BMS_HUM,
    CAN_PACKET_BMS_SOC_SOH_TEMP_STAT,
    CAN_PACKET_PSW_STAT,
    CAN_PACKET_PSW_SWITCH,
    CAN_PACKET_BMS_HW_DATA_1,
    CAN_PACKET_BMS_HW_DATA_2,
    CAN_PACKET_BMS_HW_DATA_3,
    CAN_PACKET_BMS_HW_DATA_4,
    CAN_PACKET_BMS_HW_DATA_5,
    CAN_PACKET_BMS_AH_WH_CHG_TOTAL,
    CAN_PACKET_BMS_AH_WH_DIS_TOTAL,
    CAN_PACKET_UPDATE_PID_POS_OFFSET,
    CAN_PACKET_POLL_ROTOR_POS,
    CAN_PACKET_NOTIFY_BOOT,
    CAN_PACKET_STATUS_6,
    //(int)enumeration value is out of "int" range�������
    CAN_PACKET_MAKE_ENUM_32_BITS = (int)0xFFFFFFFF,
} CAN_PACKET_ID;


typedef struct _vesc_packet {
    int32_t erpm;
    int16_t duty;
    int16_t pos;
} VescPacket;




extern VescPacket vesc_packet[255];


void vesc_can_rx_disp(uint32_t ExtId, uint8_t RxMsg[]);



HAL_StatusTypeDef Vesc_Set_Current(CAN_HandleTypeDef* _hcan, uint8_t vesc_id, int32_t current);
HAL_StatusTypeDef Vesc_Set_ERPM(CAN_HandleTypeDef* _hcan, uint8_t vesc_id, int32_t erpm);
HAL_StatusTypeDef Vesc_Set_Duty(CAN_HandleTypeDef* _hcan, uint8_t vesc_id, int32_t duty);
HAL_StatusTypeDef Vesc_Set_Brake_Current(CAN_HandleTypeDef* _hcan, uint8_t vesc_id, int32_t brakeCurrent);
HAL_StatusTypeDef Vesc_Set_Pos(CAN_HandleTypeDef* _hcan, uint8_t vesc_id, int32_t pos);







#endif


